/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hudsonlab.view;

import hudsonlab.control.TransaccionControl;
import javax.swing.JOptionPane;

/**
 *
 * @author Daniel Felipe
 */
public class PanelPrincipal extends javax.swing.JPanel {

    /**
     * Creates new form PanelPrincipal
     */
    public PanelPrincipal() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        Acreditar = new javax.swing.JButton();
        Debitar = new javax.swing.JButton();
        Consultar = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/Pavlov.png"))); // NOI18N

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/desea.png"))); // NOI18N

        Acreditar.setText("Acreditar");
        Acreditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AcreditarActionPerformed(evt);
            }
        });

        Debitar.setText("Debitar");
        Debitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DebitarActionPerformed(evt);
            }
        });

        Consultar.setText("Consultar Saldo");
        Consultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultarActionPerformed(evt);
            }
        });

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/acredita.jpg"))); // NOI18N
        jLabel3.setText("label1");

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/debitar.jpg"))); // NOI18N

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/saldo.jpg"))); // NOI18N

        jLabel6.setText("jLabel6");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel2)
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addComponent(Acreditar)
                .addGap(224, 224, 224)
                .addComponent(Debitar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(Consultar)
                .addGap(104, 104, 104))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(21, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(132, 132, 132))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(126, 126, 126)
                        .addComponent(jLabel4)
                        .addGap(123, 123, 123)
                        .addComponent(jLabel5)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)
                .addComponent(jLabel6)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel6)
                .addGap(76, 76, 76)
                .addComponent(jLabel2)
                .addGap(66, 66, 66)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 82, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Acreditar)
                    .addComponent(Debitar)
                    .addComponent(Consultar))
                .addGap(45, 45, 45))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(138, 138, 138))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(147, 147, 147))))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void AcreditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AcreditarActionPerformed
        // TODO add your handling code here:
        String s = JOptionPane.showInputDialog(this, "Ingrese la cantidad de dinero a acreditar", "Acreditar", 3);
        try {
            Integer monto=Integer.parseInt(s);
            control.ejecutar("acreditar", hudsonlab.HudsonLab.getInstance().getUsuario(), monto);
        } catch (Exception e) {
        }
    }//GEN-LAST:event_AcreditarActionPerformed

    private void DebitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DebitarActionPerformed
        // TODO add your handling code here:
         String s = JOptionPane.showInputDialog(this, "Ingrese la cantidad de dinero a debitar", "Debitar", 3);
        try {
            Integer monto=Integer.parseInt(s);
            control.ejecutar("debitar", hudsonlab.HudsonLab.getInstance().getUsuario(), monto);
        } catch (Exception e) {
        }
    }//GEN-LAST:event_DebitarActionPerformed

    private void ConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultarActionPerformed
        // TODO add your handling code here:
        control.ejecutar("consulta", hudsonlab.HudsonLab.getInstance().getUsuario(), 0);
    }//GEN-LAST:event_ConsultarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Acreditar;
    private javax.swing.JButton Consultar;
    private javax.swing.JButton Debitar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    // End of variables declaration//GEN-END:variables
private TransaccionControl control;
public void setControl(TransaccionControl control){
    this.control=control;
}

    public void cargarUsuario(String Usuario) {
        jLabel6.setText("Bienvenido, "+Usuario+ "  ");
    }
}
